<template>
	<view class="">
		<u-toast ref="uToast" />
		<u-navbar :is-back="true" title="查看" back-icon-color='#333333' height="50" :border-bottom="false">
			<view class="" style="margin-left: 530rpx; display: flex;align-content: center;">
				<text class="iconfont icon-lajitong" style="font-size:28rpx; color:#A5A5A5;margin-top:-2rpx;"
					@click.stop="display=true"></text>
				<image src="../../static/tupian88.png" mode="widthFix" @click="changePath"
					style="width: 27rpx;margin-left: 30rpx;"></image>
			</view>
		</u-navbar>
		<u-mask :show="display">
			<view class="warp">
				<view class="rect" @tap.stop>
					<view class="tanchu">
						确认删除邮件?
					</view>
					<view class="anniu">
						<view class="" @click="display=false">
							取消
						</view>
						<view class="" @click="deleteEmail">
							确定
						</view>
					</view>
				</view>
			</view>
		</u-mask>
		<view class="blank" style="width: 100%; height: 20rpx; background-color: #F0F0F0;">
		</view>
		<view class="transmit">
			<text>{{transmit}}</text>
			<text>{{email_list.title}}</text>
			<image src="../../static/tupian93.png" mode="widthFix" style="width: 20rpx;"></image>
		</view>
		<view class="addresser">
			<text>{{addresser}}</text>
			<view class="right">
				<text>{{send_list.join(',')}}</text>
				<text>{{email_arr.join(',')}}</text>
			</view>
		</view>
		<view class="status">
			<text>{{status}}</text>
			<text>{{email_list.level}}</text>
		</view>
		<view class="time">
			<view class="">
				<text>时间</text>
				<text>{{startTime}}</text>
			</view>
		</view>
		<view class="accessory">
			<view class="">
				<text>附件:</text>
				<image src="../../static/tupian91.png" mode="widthFix" style="width: 20rpx;"></image>
				<text>{{email_list.annx}}</text>
			</view>
		</view>
		<view class="underline">
		</view>
		<view class="main_body">
			<text>{{main_body}}</text>
		</view>
		<view class="main_content" style="width:680rpx; margin-left: 35rpx; color: #333333; font-size: 24rpx;">
			<view class="" style="text-indent: 1em; width: 100%;">
				{{email_list.content}}
			</view>
			<view class="" style="text-indent: 1em; width: 100%;">
			</view>
		</view>
		<view class="bottom"
			style="width: 710rpx; height: 45rpx; margin-left: 20rpx; border-bottom:1rpx solid #dddddd;">
		</view>
		<view class="minutes">
			<image src="../../static/tupian63.png" mode="widthFix"></image>
			<view class="">
				<text></text>
				<text>{{email_list.annx}}</text>
			</view>
			<image src="../../static/tupian94.png" mode="widthFix"></image>
		</view>
	</view>
</template>

<script>
	import time from '../../time.js'
	import request from '../../request.js'
	export default {
		data() {
			return {
				transmit: '转发:',
				conference: '会议总结报告',
				addresser: '发件人:',
				name: '鹿呦呦',
				address: '32190909@163.com',
				status: '状态:',
				email_id: 1,
				importance: '重要',
				main_body: '正文',
				minutes: '会议记录.rar',
				attachment: '92.9M超大附件',
				file_content: '',
				time_list: {
					time: '时间:',
					start_date: '2020年9月23日',
					detail_time: '12:09'
				},
				display: false,
				email_index: 0,
				accessory_list: [],
				startTime: '',
				send_list: [],
				email_arr: [],
				email_list: {},
			}
		},
		onLoad(option) {
			if (option.id) {
				this.email_id = option.id;
			}
			if (option.index) {
				this.email_index = option.index;
				console.log(this.email_index);
			}
			this.emailInfo();

		},
		methods: {
			changePath() {
				if (this.email_list) {
					this.$toLink('../compose_email/compose_email', {
						obj: encodeURIComponent(JSON.stringify(this.email_list))
					})
				} else {
					this.$toLink('../compose_email/compose_email', {})
				}
			},
			emailInfo() {
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				let _this = this;
				request({
					url: base_url + 'teacher/email/emailInfo',
					data: {
						email_id: this.email_id,
					},
					method: 'post',
					success(res) {
						if (res.statusCode == 200) {
							console.log(res.data.data);
							_this.email_list = res.data.data;
							if (res.data.data.send_users != null) {
								_this.send_list = res.data.data.send_users.map(item => {
									return item.full_name;
								})
								_this.email_arr = res.data.data.send_users.map(item => {
									return item.email;
								})
								// _this.accessory_list=res.data.data.send_users.map(item => {
								// 	return item.email;
								// })
								_this.startTime = time.format(res.data.data.create_time);
							}
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			},

			//删除邮件
			deleteEmail() {
				this.display = false;
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				let _this = this;
				if (this.email_index == 0) {
					request({
						url: base_url + 'teacher/email/deleteGetEmail',
						data: {
							email_id: this.email_id,
						},
						method: 'post',
						success(res) {
							if (res.statusCode == 200) {
								console.log(res.data);
								_this.$toLink('../email/email', {})
							} else {
								_this.$refs.uToast.show({
									title: res.data.message || '系统错误',
									type: 'warning',
								})
							}

						}
					})
				} else {
					request({
						url: base_url + 'teacher/email/deleteMyEmail',
						data: {
							email_id: this.email_id,
						},
						method: 'post',
						success(res) {
							if (res.statusCode == 200) {
								console.log(res.data);
								_this.$toLink('../email/email', {})
							} else {
								_this.$refs.uToast.show({
									title: res.data.message || '系统错误',
									type: 'warning',
								})
							}

						}
					})
				}

			}
		},
	}
</script>

<style lang="scss">
	.warp {
		display: flex;
		align-items: flex-start;
		justify-content: center;
		height: 100%;

		.rect {
			margin-top: 450rpx;
			border-radius: 10rpx;
			width: 480rpx;
			height: 250rpx;
			background-color: #fff;

			.tanchu {
				width: 100%;
				height: 150rpx;
				font-size: 33rpx;
				color: #3E3E3E;
				text-align: center;
				line-height: 150rpx;
			}

			.anniu {
				width: 100%;
				height: 100rpx;
				display: flex;
				justify-content: space-around;
				align-items: center;

				view {
					border-radius: 30rpx;
					width: 150rpx;
					height: 60rpx;
					text-align: center;
					line-height: 60rpx;
					font-size: 26rpx;

					&:nth-child(1) {
						color: #2C78FE;
						margin-left: 15rpx;
						border: 1px solid #2C78FE;
						background: #fff;

					}

					&:nth-child(2) {
						color: #fff;
						margin-right: 15rpx;
						background: linear-gradient(to right, #2C78FE, #32B0FF);
					}


				}
			}
		}
	}

	.transmit {
		width: 100%;
		height: 72rpx;
		display: flex;
		justify-content: flex-start;
		background-color: #fff;
		align-items: center;

		text {
			color: #333333;
			font-size: 32rpx;

			&:nth-child(1) {
				margin-left: 20rpx;
			}

			&:nth-child(2) {
				margin-left: 20rpx;
			}
		}

		image {
			&:nth-child(3) {
				transform: rotate(90deg);
				margin-left: 400rpx;
			}
		}
	}

	.addresser {
		width: 100%;
		height: 115rpx;
		display: flex;
		justify-content: flex-start;
		overflow: hidden;

		text {
			&:nth-child(1) {
				margin-top: 15rpx;
				font-size: 24rpx;
				color: #999999;
				width: 150rpx;
				margin-left: 20rpx;
			}
		}

		.right {
			margin-top: 15rpx;
			margin-left: 10rpx;
			width: 500rpx;
			height: 67rpx;
			// overflow: hidden;
			display: flex;
			flex-direction: column;
			justify-content: flex-start;


			text {
				color: #333333;
				margin: 0;
				font-size: 24rpx;

				&:nth-child(2) {
					margin-top: 19rpx;
				}
			}
		}
	}

	.status {
		width: 100%;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		height: 26rpx;

		text {
			font-size: 24rpx;

			&:nth-child(1) {
				color: #999999;
				margin-left: 54rpx;
			}

			&:nth-child(2) {
				margin-left: 19rpx;
				color: #ffa100;
			}
		}

	}

	.time {
		width: 100%;

		view {
			&:nth-child(1) {
				margin-top: 33rpx;
				width: 100%;
				height: 26rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					color: #999999;
					font-size: 24rpx;

					&:nth-child(1) {
						margin-left: 56rpx;
					}

					&:nth-child(2) {
						margin-left: 10rpx;
					}

					&:nth-child(3) {
						margin-left: 10rpx;
					}
				}
			}
		}
	}

	.accessory {
		width: 100%;

		view {

			&:nth-child(1) {
				margin-top: 28rpx;
				width: 100%;
				height: 26rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					font-size: 24rpx;

					&:nth-child(1) {
						margin-left: 56rpx;
						color: #999999;
					}

					&:nth-child(3) {
						margin-left: 15rpx;
						color: #333333;
					}
				}

				image {
					&:nth-child(2) {
						margin-left: 20rpx;
					}
				}
			}
		}


	}

	.underline {
		width: 710rpx;
		height: 28rpx;
		margin-left: 20rpx;
		border-bottom: 1rpx solid #dddddd;
	}

	.main_body {
		width: 100%;
		height: 63rpx;
		width: 710rpx;
		margin-left: 20rpx;
		display: flex;
		justify-content: flex-start;
		align-items: center;

		text {
			&:nth-child(1) {
				color: #999999;
				font-size: 25rpx;
				margin-left: 6rpx;
			}
		}
	}

	.minutes {
		width: 100%;
		height: 93rpx;
		display: flex;
		justify-content: flex-start;


		image {
			&:nth-child(1) {
				width: 39rpx;
				margin-left: 20rpx;
				margin-top: 16rpx;
			}

			&:nth-child(3) {
				margin-top: 25rpx;
				width: 50rpx;
				margin-left: 170rpx;
			}
		}

		view {
			&:nth-child(2) {
				margin-left: 45rpx;
				margin-top: 12rpx;
				width: 400rpx;
				height: 55rpx;
				display: flex;
				flex-direction: column;
				justify-content: flex-start;

				text {
					&:nth-child(1) {
						color: #333333;
						font-size: 24rpx;
					}

					&:nth-child(2) {
						color: #999999;
						width: 400rpx;
						overflow: hidden;
						font-size: 18rpx;
					}
				}


			}
		}
	}
</style>
